# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=mc
pkgver=4.8.28
pkgrel=0
pkgdesc="Filemanager/shell that emulates Norton Commander"
options="!check" # https://midnight-commander.org/ticket/3972#comment:2
url="https://www.midnight-commander.org"
arch="all"
license="GPL-3.0-or-later"
subpackages="$pkgname-doc $pkgname-lang"
makedepends="e2fsprogs-dev glib-dev libssh2-dev slang-dev perl gpm-dev"
source="https://www.midnight-commander.org/downloads/mc-$pkgver.tar.xz
	fix-cchar_t.patch
	alpine_syntax.patch"


build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--libexecdir=/usr/lib \
		--mandir=/usr/share/man \
		--sysconfdir=/etc \
		--enable-background \
		--enable-charset \
		--enable-largefile \
		--enable-vfs-sftp \
		--with-internal-edit \
		--with-mmap \
		--with-screen=slang \
		--with-subshell \
		--with-gpm-mouse \
		--without-included-gettext \
		--without-x
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	rm -fr "$pkgdir"/usr/share/man/??
}

doc() {
	default_doc
	mkdir -p "$subpkgdir"/usr/share/doc
	mv "$pkgdir"/usr/share/mc/examples \
		"$subpkgdir"/usr/share/doc/mc
	find "$pkgdir"/usr/lib/mc -name "README*" \
		-exec mv {} "$subpkgdir"/usr/share/doc/mc/ \;
}

lang() {
	default_lang
	mkdir -p "$subpkgdir"/usr/share/mc/help \
		"$subpkgdir"/usr/share/mc/hints
	mv "$pkgdir"/usr/share/mc/help/mc.hlp.* \
		"$subpkgdir"/usr/share/mc/help/
	mv "$pkgdir"/usr/share/mc/hints/mc.hint.* \
		"$subpkgdir"/usr/share/mc/hints/
}

sha512sums="
ca3b3a57281e9387cb52bf1fcfc3f39a4d5f438aafc256dc492c192678824f67c983a852c759664efc5bc6d0de471c9b3929834f8301f6302ca1ebeee513fdfd  mc-4.8.28.tar.xz
7d4c52ada69f9d66fda92a07d04de2a3060a7e5eed4cac21dfdbbcac69ab28f2c6debbfbcc84f9e6fed8587b2a14a929b3655c291323fc4c9b9872ea44f84f32  fix-cchar_t.patch
47aa001e8c20a24631617d665fd0d81b269ebad96696c4bd70c7040bbca713868e02fe53dfaee9a775a57f35a0e7c9e44ce299037379e249ad27354a78d905c3  alpine_syntax.patch
"
